import com.work.demo.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-08-30
 * Time: 18:14
 */
public class GetBean {
    public static void main(String[] args) {
        // 1.获取 Spring 上下文对象
        BeanFactory beanFactory =
                new XmlBeanFactory(new ClassPathResource("spring-config.xml"));
        // 2.得到 Bean 【依赖查找 - 》IoC 的一种实现方式】
        User user = beanFactory.getBean("user",User.class);
        // 3.使用 Bean 对象（非必须）
        user.sayHi();
    }
}
